package com.woniuxy.intellihome.controller.front;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.intellihome.entity.Category;
import com.woniuxy.intellihome.entity.GoodsSpu;
import com.woniuxy.intellihome.entity.Sku;
import com.woniuxy.intellihome.entity.User;
import com.woniuxy.intellihome.service.CategoryService;
import com.woniuxy.intellihome.service.GoodsSpuService;
import com.woniuxy.intellihome.service.SkuService;
import com.woniuxy.intellihome.service.VgoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
@Slf4j
@Controller()
@RequestMapping()
public class IndexController {
    @Autowired
    private GoodsSpuService goodsSpuService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private VgoodsService vGoodsService;
    @Autowired
    private SkuService skuService;


    /**
     * 首页展示
     */
    @GetMapping("/")
    public String list(Model model, HttpSession session) {
        List<Category> category = categoryService.getByStatus();
        List<Sku> goodsNews = skuService.getNew();
        List<Sku> goodsHots = skuService.getHot();
        System.out.println(goodsNews);
        User user = (User) session.getAttribute("user1");
        model.addAttribute("user", user);
        model.addAttribute("goodsNew", goodsNews);
        model.addAttribute("goodsHot", goodsHots);
        model.addAttribute("category", category);
        return "index";
    }

}

